package com.fuqi.android.zhongcai.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.fuqi.android.zhongcai.application.UniApplication;
import com.fuqi.android.zhongcai.base.Constants;
import com.fuqi.android.zhongcai.service.ImageUploadService;
import com.fuqi.android.zhongcai.sql.dao.SQLDao;
import com.fuqi.framework.utils.NetworkUtils;

/**
 * Created by Bruce on 2016/11/14.
 */
public class NetworkReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.e("ccqx","onReceive");
        if(NetworkUtils.isCanUploadImg(context)) {
            int count = SQLDao.getInstance(context).selectCacheCount();
            if (count > 0) {
                switch (UniApplication.getInstance().getCurrentRole()) { // 是工人才能提交
                    case Constants.ROLE_SGGR:
                        context.startService(new Intent(context, ImageUploadService.class));
                        break;

                }
            }
        }
    }
}
